/*
 Navicat Premium Data Transfer

 Source Server         : test
 Source Server Type    : PostgreSQL
 Source Server Version : 140003
 Source Host           : localhost:5432
 Source Catalog        : Familytree
 Source Schema         : public

 Target Server Type    : PostgreSQL
 Target Server Version : 140003
 File Encoding         : 65001

 Date: 15/06/2022 16:52:19
*/


-- ----------------------------
-- Table structure for common
-- ----------------------------
DROP TABLE IF EXISTS "public"."common";
CREATE TABLE "public"."common" (
  "z_id" char(20) COLLATE "pg_catalog"."default" NOT NULL,
  "z_name" char(20) COLLATE "pg_catalog"."default",
  "fx_id" char(20) COLLATE "pg_catalog"."default" NOT NULL,
  "fx_name" char(20) COLLATE "pg_catalog"."default"
)
;

-- ----------------------------
-- Records of common
-- ----------------------------
INSERT INTO "public"."common" VALUES ('1                   ', '关系类型                ', '1                   ', '父亲                  ');
INSERT INTO "public"."common" VALUES ('1                   ', '关系类型                ', '2                   ', '养父                  ');
INSERT INTO "public"."common" VALUES ('1                   ', '关系类型                ', '3                   ', '养母                  ');
INSERT INTO "public"."common" VALUES ('1                   ', '关系类型                ', '4                   ', '母亲                  ');
INSERT INTO "public"."common" VALUES ('1                   ', '关系类型                ', '5                   ', '妻子                  ');
INSERT INTO "public"."common" VALUES ('1                   ', '关系类型                ', '6                   ', '离异妻子                ');
INSERT INTO "public"."common" VALUES ('1                   ', '关系类型                ', '7                   ', '未婚情人                ');
INSERT INTO "public"."common" VALUES ('1                   ', '关系类型                ', '8                   ', '女儿                  ');
INSERT INTO "public"."common" VALUES ('1                   ', '关系类型                ', '9                   ', '儿子                  ');
INSERT INTO "public"."common" VALUES ('1                   ', '关系类型                ', '10                  ', '私生儿子                ');
INSERT INTO "public"."common" VALUES ('1                   ', '关系类型                ', '11                  ', '私生女儿                ');
INSERT INTO "public"."common" VALUES ('2                   ', '事件类别                ', '1                   ', '结婚                  ');
INSERT INTO "public"."common" VALUES ('2                   ', '事件类别                ', '2                   ', '晋升                  ');
INSERT INTO "public"."common" VALUES ('2                   ', '事件类别                ', '3                   ', '重病                  ');
INSERT INTO "public"."common" VALUES ('2                   ', '事件类别                ', '4                   ', '重要成果                ');
INSERT INTO "public"."common" VALUES ('2                   ', '事件类别                ', '5                   ', '交通事故                ');
INSERT INTO "public"."common" VALUES ('2                   ', '事件类别                ', '6                   ', '升学                  ');
INSERT INTO "public"."common" VALUES ('1                   ', '关系类型                ', '12                  ', '丈夫                  ');

-- ----------------------------
-- Table structure for event
-- ----------------------------
DROP TABLE IF EXISTS "public"."event";
CREATE TABLE "public"."event" (
  "family_id" char(20) COLLATE "pg_catalog"."default",
  "event_time" char(60) COLLATE "pg_catalog"."default",
  "event_type" char(60) COLLATE "pg_catalog"."default",
  "event_des" char(255) COLLATE "pg_catalog"."default",
  "event_fj" char(255) COLLATE "pg_catalog"."default",
  "is_del" bool
)
;

-- ----------------------------
-- Records of event
-- ----------------------------
INSERT INTO "public"."event" VALUES ('666                 ', '2022/6/16                                                   ', '曲某课设过了                                                      ', '盲猜天气晴，盲猜课设过了                                                                                                                                                                                                                                                   ', '暂无                                                                                                                                                                                                                                                             ', 't');
INSERT INTO "public"."event" VALUES ('88                  ', 'ter                                                         ', 'ret                                                         ', 're                                                                                                                                                                                                                                                             ', 'ert                                                                                                                                                                                                                                                            ', 't');
INSERT INTO "public"."event" VALUES ('001                 ', '1927/12/01                                                  ', '结婚                                                          ', '离弃妻妾，与宋美龄于12月1日结婚，从此与宋子文、孔祥熙联姻。                                                                                                                                                                                                                                ', '暂无                                                                                                                                                                                                                                                             ', 'f');
INSERT INTO "public"."event" VALUES ('001                 ', '1975/04/05                                                  ', '重病                                                          ', '因心脏病在台北士林寓所去世                                                                                                                                                                                                                                                  ', '暂时没有                                                                                                                                                                                                                                                           ', 'f');
INSERT INTO "public"."event" VALUES ('354                 ', '345                                                         ', '结婚                                                          ', '3                                                                                                                                                                                                                                                              ', '243                                                                                                                                                                                                                                                            ', 't');
INSERT INTO "public"."event" VALUES ('55                  ', '66                                                          ', '54                                                          ', '54                                                                                                                                                                                                                                                             ', '54                                                                                                                                                                                                                                                             ', 'f');

-- ----------------------------
-- Table structure for family
-- ----------------------------
DROP TABLE IF EXISTS "public"."family";
CREATE TABLE "public"."family" (
  "family_id" char(20) COLLATE "pg_catalog"."default" NOT NULL,
  "people_id" char(20) COLLATE "pg_catalog"."default",
  "family_name" char(20) COLLATE "pg_catalog"."default",
  "family_sex" char(20) COLLATE "pg_catalog"."default",
  "family_birth" char(20) COLLATE "pg_catalog"."default",
  "family_die" char(20) COLLATE "pg_catalog"."default",
  "is_del" bool
)
;

-- ----------------------------
-- Records of family
-- ----------------------------
INSERT INTO "public"."family" VALUES ('4                   ', '3                   ', '6585                ', '657                 ', '576                 ', '575                 ', 't');
INSERT INTO "public"."family" VALUES ('001                 ', '3                   ', '蒋介石                 ', '男                   ', '1887/10/31          ', '1975/04/05          ', 'f');
INSERT INTO "public"."family" VALUES ('002                 ', '2                   ', '宋美龄                 ', '女                   ', '1897/3/？            ', '2003/10/24          ', 'f');
INSERT INTO "public"."family" VALUES ('003                 ', '3                   ', '蒋经国                 ', '男                   ', '1910/04/27          ', '1988/01/13          ', 'f');
INSERT INTO "public"."family" VALUES ('004                 ', '3                   ', '蒋纬国                 ', '男                   ', '1916/10/06          ', '1997/09/23          ', 'f');
INSERT INTO "public"."family" VALUES ('005                 ', '3                   ', '蒋孝文                 ', '男                   ', '1935/12/14          ', '1989/04/14          ', 'f');
INSERT INTO "public"."family" VALUES ('006                 ', '3                   ', '蒋孝章                 ', '男                   ', '1938/?/?            ', '?/?/?               ', 'f');
INSERT INTO "public"."family" VALUES ('007                 ', '3                   ', '蒋孝武                 ', '男                   ', '1945/04/25          ', '1991/07/01          ', 'f');
INSERT INTO "public"."family" VALUES ('008                 ', '3                   ', '蒋孝勇                 ', '男                   ', '1948/10/27          ', '1996/12/22          ', 'f');
INSERT INTO "public"."family" VALUES ('009                 ', '3                   ', '蒋孝严                 ', '男                   ', '1942/03/01          ', '------              ', 'f');
INSERT INTO "public"."family" VALUES ('010                 ', '3                   ', '蒋孝慈                 ', '男                   ', '1942/03/01          ', '1996/02/04          ', 'f');
INSERT INTO "public"."family" VALUES ('011                 ', '3                   ', '蒋友兰                 ', '女                   ', '1961/?/?            ', '未知                  ', 'f');

-- ----------------------------
-- Table structure for gener
-- ----------------------------
DROP TABLE IF EXISTS "public"."gener";
CREATE TABLE "public"."gener" (
  "gen_id" char(255) COLLATE "pg_catalog"."default",
  "gen_name" char(20) COLLATE "pg_catalog"."default",
  "gen_father" char(20) COLLATE "pg_catalog"."default",
  "gen_mother" char(20) COLLATE "pg_catalog"."default",
  "gen_no" char(20) COLLATE "pg_catalog"."default",
  "is_del" bool
)
;

-- ----------------------------
-- Records of gener
-- ----------------------------
INSERT INTO "public"."gener" VALUES ('2                                                                                                                                                                                                                                                              ', '蒋经国                 ', '蒋介石                 ', '毛福梅                 ', '第二代                 ', 'f');
INSERT INTO "public"."gener" VALUES ('4                                                                                                                                                                                                                                                              ', '蒋孝文                 ', '蒋经国                 ', '蒋方良                 ', '第三代                 ', 'f');
INSERT INTO "public"."gener" VALUES ('5                                                                                                                                                                                                                                                              ', '蒋孝章                 ', '蒋经国                 ', '蒋方良                 ', '第三代                 ', 'f');
INSERT INTO "public"."gener" VALUES ('6                                                                                                                                                                                                                                                              ', '蒋孝武                 ', '蒋经国                 ', '蒋方良                 ', '第三代                 ', 'f');
INSERT INTO "public"."gener" VALUES ('8                                                                                                                                                                                                                                                              ', '蒋孝慈                 ', '蒋经国                 ', '章亚若                 ', '第三代                 ', 'f');
INSERT INTO "public"."gener" VALUES ('9                                                                                                                                                                                                                                                              ', '蒋孝严                 ', '蒋经国                 ', '章亚若                 ', '第三代                 ', 'f');
INSERT INTO "public"."gener" VALUES ('11                                                                                                                                                                                                                                                             ', '蒋友梅                 ', '蒋孝文                 ', '徐乃锦                 ', '第四代                 ', 'f');
INSERT INTO "public"."gener" VALUES ('12                                                                                                                                                                                                                                                             ', '俞祖声                 ', '俞扬和                 ', '蒋孝章                 ', '第四代                 ', 'f');
INSERT INTO "public"."gener" VALUES ('13                                                                                                                                                                                                                                                             ', '蒋友松                 ', '蒋孝武                 ', '汪长诗                 ', '第四代                 ', 'f');
INSERT INTO "public"."gener" VALUES ('14                                                                                                                                                                                                                                                             ', '蒋友兰                 ', '蒋孝武                 ', '汪长诗                 ', '第四代                 ', 'f');
INSERT INTO "public"."gener" VALUES ('10                                                                                                                                                                                                                                                             ', '蒋孝刚                 ', '蒋纬国                 ', '邱爱伦                 ', '第三代                 ', 't');
INSERT INTO "public"."gener" VALUES ('6777                                                                                                                                                                                                                                                           ', '23                  ', '21                  ', '43                  ', '第二代                 ', 'f');
INSERT INTO "public"."gener" VALUES ('7                                                                                                                                                                                                                                                              ', '蒋蒋孝                 ', '蒋经国                 ', '蒋方良                 ', '第三代                 ', 't');

-- ----------------------------
-- Table structure for menu
-- ----------------------------
DROP TABLE IF EXISTS "public"."menu";
CREATE TABLE "public"."menu" (
  "menu_id" int4 NOT NULL,
  "menu_address" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "menu_level" int4 NOT NULL,
  "menu_name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL
)
;

-- ----------------------------
-- Records of menu
-- ----------------------------
INSERT INTO "public"."menu" VALUES (9, '/relation1', 1, '查询人员关系信息');
INSERT INTO "public"."menu" VALUES (10, '/event1', 1, '查询人员事件信息');
INSERT INTO "public"."menu" VALUES (1, '/family', 2, '个人信息');
INSERT INTO "public"."menu" VALUES (2, '/people', 2, '家族信息');
INSERT INTO "public"."menu" VALUES (3, '/event', 2, '人员事件信息');
INSERT INTO "public"."menu" VALUES (4, '/relation', 2, '人员关系信息');
INSERT INTO "public"."menu" VALUES (5, '/gener', 2, '家庭成员信息');
INSERT INTO "public"."menu" VALUES (11, '/tongjir', 2, '同代人统计');
INSERT INTO "public"."menu" VALUES (12, '/common', 2, '共通表');
INSERT INTO "public"."menu" VALUES (13, '/tree', 2, '家庭成员展示');
INSERT INTO "public"."menu" VALUES (6, '/people1', 1, '查询家族');
INSERT INTO "public"."menu" VALUES (7, '/gener1', 1, '查询家庭成员信息');

-- ----------------------------
-- Table structure for people
-- ----------------------------
DROP TABLE IF EXISTS "public"."people";
CREATE TABLE "public"."people" (
  "people_id" char(20) COLLATE "pg_catalog"."default" NOT NULL,
  "user_id" char(20) COLLATE "pg_catalog"."default",
  "people_name" char(20) COLLATE "pg_catalog"."default",
  "description" char(20) COLLATE "pg_catalog"."default",
  "create_time" char(255) COLLATE "pg_catalog"."default",
  "is_del" bool
)
;

-- ----------------------------
-- Records of people
-- ----------------------------
INSERT INTO "public"."people" VALUES ('1                   ', 'xwang               ', '蒋氏家族                ', '因课设被创建              ', '2022/6/15                                                                                                                                                                                                                                                      ', 'f');
INSERT INTO "public"."people" VALUES ('3                   ', 'ck567               ', '曲氏家族                ', '我随便测试的              ', '2022/06/15                                                                                                                                                                                                                                                     ', 'f');
INSERT INTO "public"."people" VALUES ('54                  ', '34                  ', '43                  ', '546                 ', '5                                                                                                                                                                                                                                                              ', 't');
INSERT INTO "public"."people" VALUES ('2                   ', 'xsong               ', '宋氏家族                ', '课设                  ', '2022/6/15                                                                                                                                                                                                                                                      ', 'f');

-- ----------------------------
-- Table structure for relation
-- ----------------------------
DROP TABLE IF EXISTS "public"."relation";
CREATE TABLE "public"."relation" (
  "family_id1" char(20) COLLATE "pg_catalog"."default" NOT NULL,
  "id1_name" char(255) COLLATE "pg_catalog"."default",
  "family_id2" char(20) COLLATE "pg_catalog"."default" NOT NULL,
  "id2_name" char(255) COLLATE "pg_catalog"."default",
  "relation_type" char(255) COLLATE "pg_catalog"."default",
  "is_del" bool
)
;

-- ----------------------------
-- Records of relation
-- ----------------------------
INSERT INTO "public"."relation" VALUES ('006                 ', '蒋经国                                                                                                                                                                                                                                                            ', '001                 ', '蒋介石                                                                                                                                                                                                                                                            ', '儿子                                                                                                                                                                                                                                                             ', 'f');
INSERT INTO "public"."relation" VALUES ('007                 ', '蒋纬国                                                                                                                                                                                                                                                            ', '001                 ', '蒋介石                                                                                                                                                                                                                                                            ', '儿子                                                                                                                                                                                                                                                             ', 'f');
INSERT INTO "public"."relation" VALUES ('008                 ', '蒋瑶光                                                                                                                                                                                                                                                            ', '001                 ', '蒋介石                                                                                                                                                                                                                                                            ', '养女                                                                                                                                                                                                                                                             ', 'f');
INSERT INTO "public"."relation" VALUES ('010                 ', '蒋孝文                                                                                                                                                                                                                                                            ', '006                 ', '蒋经国                                                                                                                                                                                                                                                            ', '女儿                                                                                                                                                                                                                                                             ', 'f');
INSERT INTO "public"."relation" VALUES ('002                 ', '宋美龄                                                                                                                                                                                                                                                            ', '001                 ', '蒋介石                                                                                                                                                                                                                                                            ', '妻子                                                                                                                                                                                                                                                             ', 't');
INSERT INTO "public"."relation" VALUES ('010                 ', '蒋孝文                                                                                                                                                                                                                                                            ', '006                 ', '蒋经国                                                                                                                                                                                                                                                            ', '女儿                                                                                                                                                                                                                                                             ', 'f');
INSERT INTO "public"."relation" VALUES ('010                 ', '蒋孝文                                                                                                                                                                                                                                                            ', '006                 ', '蒋经国                                                                                                                                                                                                                                                            ', '女儿                                                                                                                                                                                                                                                             ', 'f');
INSERT INTO "public"."relation" VALUES ('000                 ', '宋美龄                                                                                                                                                                                                                                                            ', '001                 ', '蒋介石                                                                                                                                                                                                                                                            ', '妻子                                                                                                                                                                                                                                                             ', 't');
INSERT INTO "public"."relation" VALUES ('010                 ', '蒋孝文                                                                                                                                                                                                                                                            ', '006                 ', '蒋经国                                                                                                                                                                                                                                                            ', '女儿                                                                                                                                                                                                                                                             ', 't');
INSERT INTO "public"."relation" VALUES ('324                 ', '324                                                                                                                                                                                                                                                            ', '42                  ', '34                                                                                                                                                                                                                                                             ', '453                                                                                                                                                                                                                                                            ', 't');
INSERT INTO "public"."relation" VALUES ('002                 ', '宋美龄                                                                                                                                                                                                                                                            ', '001                 ', '蒋介石                                                                                                                                                                                                                                                            ', '前妻                                                                                                                                                                                                                                                             ', 't');
INSERT INTO "public"."relation" VALUES ('002                 ', '宋美龄                                                                                                                                                                                                                                                            ', '001                 ', '蒋介石                                                                                                                                                                                                                                                            ', '前妻                                                                                                                                                                                                                                                             ', 't');
INSERT INTO "public"."relation" VALUES ('002                 ', '宋美龄                                                                                                                                                                                                                                                            ', '001                 ', '蒋介石                                                                                                                                                                                                                                                            ', '前妻                                                                                                                                                                                                                                                             ', 't');
INSERT INTO "public"."relation" VALUES ('002                 ', '宋美龄                                                                                                                                                                                                                                                            ', '001                 ', '蒋介石                                                                                                                                                                                                                                                            ', '妻子                                                                                                                                                                                                                                                             ', 'f');

-- ----------------------------
-- Table structure for staff
-- ----------------------------
DROP TABLE IF EXISTS "public"."staff";
CREATE TABLE "public"."staff" (
  "staff_id" int4 NOT NULL,
  "staff_name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "staff_password" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "staff_level" int4 NOT NULL,
  "staff_remarks" varchar(255) COLLATE "pg_catalog"."default",
  "is_del" bool NOT NULL DEFAULT false,
  "update_time" timestamptz(0) NOT NULL
)
;

-- ----------------------------
-- Records of staff
-- ----------------------------
INSERT INTO "public"."staff" VALUES (20210702, 'testtest', 'testtest', 1, '普通用户', 'f', '2021-06-30 11:06:24+08');
INSERT INTO "public"."staff" VALUES (20210656, 'lemon', 'lemon', 1, '普通用户', 'f', '2021-06-30 11:06:24+08');
INSERT INTO "public"."staff" VALUES (2, 'qjx1112', '12345678', 2, '管理员', 'f', '2022-05-24 11:04:59+08');
INSERT INTO "public"."staff" VALUES (2020082114, 'xwang', '123456', 1, '普通用户', 'f', '2021-06-30 11:06:24+08');
INSERT INTO "public"."staff" VALUES (12345, '12345', '12345', 1, '普通用户', 'f', '2022-06-13 11:06:24+08');
INSERT INTO "public"."staff" VALUES (1234567, '1234567', '1234567', 1, '普通用户', 'f', '2022-06-13 11:06:24+08');
INSERT INTO "public"."staff" VALUES (3, 'MFM123', 'MFM123', 1, '普通用户', 'f', '2022-06-14 11:06:24+08');

-- ----------------------------
-- Table structure for tji
-- ----------------------------
DROP TABLE IF EXISTS "public"."tji";
CREATE TABLE "public"."tji" (
  "gen_no" char(20) COLLATE "pg_catalog"."default",
  "count" int4
)
;

-- ----------------------------
-- Records of tji
-- ----------------------------

-- ----------------------------
-- Function structure for count_common
-- ----------------------------
DROP FUNCTION IF EXISTS "public"."count_common"();
CREATE OR REPLACE FUNCTION "public"."count_common"()
  RETURNS "pg_catalog"."trigger" AS $BODY$

declare
counts integer;

begin
   select count(*) into counts from common;
    return counts;
end;
$BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;

-- ----------------------------
-- Function structure for count_event
-- ----------------------------
DROP FUNCTION IF EXISTS "public"."count_event"();
CREATE OR REPLACE FUNCTION "public"."count_event"()
  RETURNS "pg_catalog"."trigger" AS $BODY$

declare
counts integer;

begin
   select count(*) into counts from event;
    return counts;
end;
$BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;

-- ----------------------------
-- Function structure for count_family
-- ----------------------------
DROP FUNCTION IF EXISTS "public"."count_family"();
CREATE OR REPLACE FUNCTION "public"."count_family"()
  RETURNS "pg_catalog"."trigger" AS $BODY$

declare
counts integer;

begin
   select count(*) into counts from family;
    return counts;
end;
$BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;

-- ----------------------------
-- Function structure for count_people
-- ----------------------------
DROP FUNCTION IF EXISTS "public"."count_people"();
CREATE OR REPLACE FUNCTION "public"."count_people"()
  RETURNS "pg_catalog"."trigger" AS $BODY$

declare
counts integer;

begin
   select count(*) into counts from people;
    return counts;
end;
$BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;

-- ----------------------------
-- Function structure for count_relation
-- ----------------------------
DROP FUNCTION IF EXISTS "public"."count_relation"();
CREATE OR REPLACE FUNCTION "public"."count_relation"()
  RETURNS "pg_catalog"."trigger" AS $BODY$

declare
counts integer;

begin
   select count(*) into counts from relation;
    return counts;
end;
$BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;

-- ----------------------------
-- Function structure for delete_family
-- ----------------------------
DROP FUNCTION IF EXISTS "public"."delete_family"();
CREATE OR REPLACE FUNCTION "public"."delete_family"()
  RETURNS "pg_catalog"."trigger" AS $BODY$

begin
	delete from event where family_id = old.family_id;
	return old;
end;
$BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;

-- ----------------------------
-- Function structure for delete_people
-- ----------------------------
DROP FUNCTION IF EXISTS "public"."delete_people"();
CREATE OR REPLACE FUNCTION "public"."delete_people"()
  RETURNS "pg_catalog"."trigger" AS $BODY$
begin
	delete from family where people_id = old.people_id;
	return old;
end;
$BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;

-- ----------------------------
-- Function structure for family_delete_trigger
-- ----------------------------
DROP FUNCTION IF EXISTS "public"."family_delete_trigger"();
CREATE OR REPLACE FUNCTION "public"."family_delete_trigger"()
  RETURNS "pg_catalog"."trigger" AS $BODY$
begin
	delete from event where family_id = old.family_id;
	return old;
end;
$BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;

-- ----------------------------
-- Function structure for family_delete_trigger_fun
-- ----------------------------
DROP FUNCTION IF EXISTS "public"."family_delete_trigger_fun"();
CREATE OR REPLACE FUNCTION "public"."family_delete_trigger_fun"()
  RETURNS "pg_catalog"."trigger" AS $BODY$
begin
    delete from gener where gener_id = old.family_id;
    return old;
end;
$BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;

-- ----------------------------
-- Function structure for people_delete_trigger
-- ----------------------------
DROP FUNCTION IF EXISTS "public"."people_delete_trigger"();
CREATE OR REPLACE FUNCTION "public"."people_delete_trigger"()
  RETURNS "pg_catalog"."trigger" AS $BODY$
begin
	delete from family where people_id = old.people_id;
	return old;
end;
$BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;

-- ----------------------------
-- Function structure for update_people
-- ----------------------------
DROP FUNCTION IF EXISTS "public"."update_people"();
CREATE OR REPLACE FUNCTION "public"."update_people"()
  RETURNS "pg_catalog"."trigger" AS $BODY$
	begin 
		update family set people_id = new.people_id;
		return new;
	end;
	$BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;

-- ----------------------------
-- Triggers structure for table family
-- ----------------------------
CREATE TRIGGER "delete_trigger" AFTER DELETE ON "public"."family"
FOR EACH ROW
EXECUTE PROCEDURE "public"."family_delete_trigger"();

-- ----------------------------
-- Primary Key structure for table family
-- ----------------------------
ALTER TABLE "public"."family" ADD CONSTRAINT "family_pkey" PRIMARY KEY ("family_id");

-- ----------------------------
-- Triggers structure for table people
-- ----------------------------
CREATE TRIGGER "delete_peoples_trigger" AFTER DELETE ON "public"."people"
FOR EACH ROW
EXECUTE PROCEDURE "public"."delete_people"();
CREATE TRIGGER "update_people_trigger" AFTER UPDATE OF "people_id" ON "public"."people"
FOR EACH ROW
EXECUTE PROCEDURE "public"."update_people"();

-- ----------------------------
-- Primary Key structure for table people
-- ----------------------------
ALTER TABLE "public"."people" ADD CONSTRAINT "people_pkey" PRIMARY KEY ("people_id");

-- ----------------------------
-- Primary Key structure for table staff
-- ----------------------------
ALTER TABLE "public"."staff" ADD CONSTRAINT "staff_pkey" PRIMARY KEY ("staff_id");
